home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DSIIC2.ARJ / BARDEMO2.C < prev    next >
C/C++ Source or Header  |  1991-07-15  |  3KB  |  124 lines

  1. /* Copyright (c) James L. Pinson 1990,1991  */
  2.  
  3. /**********************   BARDEMO2.C   ***************************/
  4.  
  5. /* Demonstration of a stacked (multi-level) horizontal
  6.    moving light bar menu. */
  7.  
  8. #include "mydef.h"
  9. #include <stdio.h>
  10.  
  11. /* function prototypes */
  12.  
  13. int fake(void);
  14. int prtdemo(void);
  15. int printer(void);
  16. int lpt1(void);
  17. int lpt2(void);
  18. int text(void);
  19.  
  20.  
  21. int start(int argc, char *argv[])
  22. {
  23. extern struct screen_structure scr;
  24. extern struct window_structure w[];
  25.  
  26. int win1;
  27. int return_code;
  28.  
  29.  /* prepare menu */
  30.  struct bar_struc main_menu [6]={
  31.             "Sort",     "Sort the data file",        fake,    0,
  32.             "Print",    "Printer, Text-file" ,       prtdemo, 0,
  33.             "Delete",   "Delete current data file",  fake,    0,
  34.             "Copy",     "Copy data file to backup",  fake,    0,
  35.             "Quit",     "Quit and return to DOS",    NULL,    1,
  36.             "\0"      /* mark the end of the options list */
  37.  };
  38.  
  39.    cls();
  40.    /* make a window for the menu */
  41.    win1=win_make(2,2,scr.columns-2,2,STD_FRAME,"",
  42.                  scr.current,scr.current);
  43.  
  44.     /* create the first menu */
  45.     return_code= bar_menu(main_menu,scr.normal,scr.inverse);
  46.  
  47.     win_delete(win1);      /* remove window */
  48.     return(return_code);  /* pass along the return code */
  49. }
  50.  
  51.  
  52. int prtdemo(void)
  53. {
  54. extern struct screen_structure scr;
  55. extern struct window_structure w[];
  56.  
  57. int win2;
  58. int return_code;
  59.  
  60.  struct bar_struc main_menu [3]={
  61.             "Printer",   "Lpt1:, Lpt2:",               printer, 0,
  62.             "Text-file", "Send output to a text file", text,    0,
  63.             "\0"      /* mark the end of the options list */
  64.  };
  65.  
  66.    win2=win_make(2,4,scr.columns-2,2,STD_FRAME,"",
  67.                  scr.current,scr.current);
  68.  
  69. return_code= bar_menu(main_menu,scr.normal,scr.inverse);
  70.  
  71.   win_delete(win2);
  72.  
  73.   return(0); /* we don't want to close the parent menu
  74.                 so we return a zero value instead of
  75.                 "return_code" */
  76. }
  77.  
  78.  
  79. int printer(void)
  80. {
  81. extern struct screen_structure scr;
  82. extern struct window_structure w[];
  83.  
  84. int win3;
  85. int return_code;
  86.  
  87.  struct bar_struc main_menu [3]={
  88.   "Lpt1:",   "Route output to printer on port lpt1:", lpt1, 0,
  89.   "lPt2:",   "Rout output to printer on port lpt2:",  lpt2, 0,
  90.   "\0"      /* mark the end of the options list */
  91.  };
  92.  
  93.    win3=win_make(2,6,scr.columns-2,2,STD_FRAME,"",
  94.                  scr.current,scr.current);
  95.  
  96. return_code= bar_menu(main_menu,scr.normal,scr.inverse);
  97.  
  98.  win_delete(win3);
  99.  return(return_code);
  100. }
  101.  
  102.  
  103. int lpt1(void)
  104. {
  105. return(1);  /* return a non-zero number to close menu */
  106. }
  107.  
  108.  
  109. int lpt2(void)
  110. {
  111. return(1);  /* return a non-zero number to close menu */
  112. }
  113.  
  114.  
  115. int text(void)
  116. {
  117. return(1);  /* return a non-zero number to close menu */
  118. }
  119.  
  120. int fake(void)
  121. {
  122. return(0);  /* return a zero to close menu */
  123. }
  124.